package ${basePackage}.generator;

import cn.hutool.core.io.resource.ClassPathResource;
import freemarker.template.TemplateException;
import ${basePackage}.model.DataModel;

import java.io.File;
import java.io.IOException;

/**
 * 动静结合代码生成
 * @author ${author}
 */
public class MainGenerator {
    public static void doGenerate(DataModel config) throws TemplateException, IOException {
        // 定义原始根路径
        String srcRootPath = "${fileConfig.inputRootPath}";
        // 定义原始目标根路径
        String destRootPath = "${fileConfig.outputRootPath}";
        String srcPath;
        String destPath;
    <#list fileConfig.files as FileInfo>
    <#if FileInfo.generateType == "static">
        // 静态代码生成
        srcPath = new File(srcRootPath, "${FileInfo.inputPath}").getAbsolutePath();
        destPath = new File(destRootPath, "${FileInfo.outputPath}").getAbsolutePath();
        StaticGenerator.doGenerate(srcPath, destPath);
    <#else>
        srcPath = new File(srcRootPath, "${FileInfo.inputPath}").getAbsolutePath();
        destPath = new File(destRootPath, "${FileInfo.outputPath}").getAbsolutePath();
        DynamicGenerator.deGenerator(srcPath, destPath, config);
    </#if>
    </#list>
    }
}
